import React, { Component } from 'react'

export default class UncontrolComponent extends Component {
  render() {
    return (
      <>
        <h1>非受控组件,值现用现取</h1>
        <form onSubmit={this.handleSubmit}>
          账号: <input type="text" ref={e => this.username = e} />
          密码: <input type="password" ref={e => this.password = e} />
          <button>登录</button>
        </form>
      </>
    )
  }
  handleSubmit = (event) => {
    event.preventDefault()
    alert(`账户:${this.username.value}, 密码: ${this.password.value}`)
  }
}
